package com.bawei.mall.product.controller;

import com.bawei.common.core.domain.R;
import com.bawei.mall.product.service.ICBrandService;
import com.bawei.mall.product.domain.Po.Brand;
import com.bawei.mall.product.domain.Po.BrandThumbsUp;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author：liurui
 * @Package：com.bawei.mall.search.controller
 * @Project：mall_cloud
 * @name：UserProductController
 */
@RestController
@Log4j2
@RequestMapping("/brand")
public class CBrandController {
    @Autowired
    private ICBrandService service;

    /**
     * 根据id查询
     * @param id
     * @return
     */
    @GetMapping("/detail/{id}")
    public R<Brand> detail(@PathVariable Integer id){
        Brand brand=service.detail(id);
        return R.ok(brand);
    }

    /**
     * 删除
     * @param brandId
     * @return
     */
    @PostMapping("/delete")
    public R delete(@RequestParam Integer brandId){
        service.delete(brandId);
        return R.ok();
    }

    /**
     * 查询关注列表
     */
    @GetMapping("/findlist")
    public R<List<BrandThumbsUp>> list(@RequestParam Integer pageNum, @RequestParam Integer pageSize){
        List<BrandThumbsUp> list=service.list();
        return R.ok(list);
    }
    /**
     * 关注品牌
     * @param brandThumbsUp
     * @return
     */
    @PostMapping("/add")
    public R add(@RequestBody BrandThumbsUp brandThumbsUp){
        service.add(brandThumbsUp);
        return R.ok();
    }

    /**
     * 收藏品牌的子类
     * @param brandThumbsUp
     * @return
     */
    @PostMapping("/addzi")
    public R addzi(@RequestBody BrandThumbsUp brandThumbsUp){
        service.addzi(brandThumbsUp);
        return R.ok();
    }

    /**
     * 删除收藏品牌的子类
     * @param
     * @return
     */
    @PostMapping("/deletezi")
    public R deletezi(@RequestParam Integer productId){
        service.deletezi(productId);
        return R.ok();
    }

    /**
     * 清空关注表
     * @param
     * @return
     */
    @PostMapping("/clear")
    public R clear(){
        service.clear();
        return R.ok();
    }

    @GetMapping("/detailup")
    public R<BrandThumbsUp> detailup(@RequestParam Integer brandId){
        BrandThumbsUp brandThumbsUp=service.detailup(brandId);
        return R.ok(brandThumbsUp);
    }
}
